#!/usr/bin/env bats

@test "filter no-around color case: 2 words" {
  cd $BATS_TEST_DIRNAME
  expected="file11:6:[01;31m[KPresent[m[K is [0;32mdejected[0m here;"
  result="$(fish -c 'tbgs Present dejected')"; [ "$result" = "$expected" ]
  expected=""
  result="$(fish -c 'tbgs present dejected')"; [ "$result" = "$expected" ]
  result="$(fish -c 'tbgs Present dejeCtEd')"; [ "$result" = "$expected" ]
  expected="file11:6:[0;32mPresent[0m is [01;31m[Kdejected[m[K here;"
  result="$(fish -c 'tbgs dejected Present')"; [ "$result" = "$expected" ]
  expected=""
  result="$(fish -c 'tbgs dejected present')"; [ "$result" = "$expected" ]
  result="$(fish -c 'tbgs dejeCtEd Present')"; [ "$result" = "$expected" ]
}

@test "filter no-around color case: 4 words" {
  cd $BATS_TEST_DIRNAME
  expected="file11:4:[01;31m[KMerry[m[K [0;32mdays[0m [0;33mwill[0m [0;34mcome[0m, believe."
  result="$(fish -c 'tbgs Merry days will come')"; [ "$result" = "$expected" ]
  result="$(fish -c 'tbgs case Merry days will come')"; [ "$result" = "$expected" ]
  expected="file11:4:[0;34mMerry[0m [01;31m[Kdays[m[K [0;32mwill[0m [0;33mcome[0m, believe."
  result="$(fish -c 'tbgs days will come Merry')"; [ "$result" = "$expected" ]
  result="$(fish -c 'tbgs case days will come Merry')"; [ "$result" = "$expected" ]
  expected=""
  result="$(fish -c 'tbgs merry days will come')"; [ "$result" = "$expected" ]
  result="$(fish -c 'tbgs Merry dAyS will come')"; [ "$result" = "$expected" ]
  result="$(fish -c 'tbgs Merry days wILl come')"; [ "$result" = "$expected" ]
  result="$(fish -c 'tbgs Merry days will COme')"; [ "$result" = "$expected" ]
  result="$(fish -c 'tbgs DaYs will come Merry')"; [ "$result" = "$expected" ]
  result="$(fish -c 'tbgs days wILl come Merry')"; [ "$result" = "$expected" ]
  result="$(fish -c 'tbgs days will CoMe Merry')"; [ "$result" = "$expected" ]
  result="$(fish -c 'tbgs days will come merry')"; [ "$result" = "$expected" ]
}

@test "filter no-around color case: 2 words partial match" {
  cd $BATS_TEST_DIRNAME
  expected="file11:6:[01;31m[KPres[m[Kent is [0;32mdeject[0med here;"
  result="$(fish -c 'tbgs Pres deject')"; [ "$result" = "$expected" ]
  expected=""
  result="$(fish -c 'tbgs pres deject')"; [ "$result" = "$expected" ]
  result="$(fish -c 'tbgs Pres dejeCt')"; [ "$result" = "$expected" ]
  expected="file11:6:[0;32mPres[0ment is [01;31m[Kdeject[m[Ked here;"
  result="$(fish -c 'tbgs deject Pres')"; [ "$result" = "$expected" ]
  expected=""
  result="$(fish -c 'tbgs deject pres')"; [ "$result" = "$expected" ]
  result="$(fish -c 'tbgs dejeCt Pres')"; [ "$result" = "$expected" ]
}

@test "filter no-around color case: 2 words word only appears in file path" {
  cd $BATS_TEST_DIRNAME
  expected=""
  result="$(fish -c 'tbgs Present file')"; [ "$result" = "$expected" ]
  result="$(fish -c 'tbgs file dejected')"; [ "$result" = "$expected" ]
  result="$(fish -c 'tbgs is file')"; [ "$result" = "$expected" ]
}
